package com.xing.xingui.ui.home;

import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.xing.ui.button.circularProgressButton.CircularProgressButton;
import com.xing.ui.expandableRecyclerView.ExpandableData;
import com.xing.ui.expandableRecyclerView.ExpandableGroupVH;
import com.xing.ui.expandableRecyclerView.ExpandableRecyclerAdapter;
import com.xing.util.DrawableBuilder;
import com.xing.xingui.R;

import java.util.ArrayList;
import java.util.List;

public class HomeFragment extends Fragment {

    private HomeViewModel homeViewModel;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        homeViewModel =
                new ViewModelProvider(this).get(HomeViewModel.class);
        View root = inflater.inflate(R.layout.fragment_home, container, false);

//        List<ExpandableData> list = new ArrayList<>();
//        for (int i = 0; i < 10; i++) {
//            ExpandableData data = new ExpandableData(ExpandableData.GROUP_TYPE);
//            data.setText("Title Group " + i);
//
//            if (i < 4) {
//                List<ExpandableData> childList = new ArrayList<>();
//                for (int j = 0; j < 3; j++) {
//                    ExpandableData child = new ExpandableData(ExpandableData.CHILD_TYPE);
//                    child.setText("Title child " + j);
//                    childList.add(child);
//                }
//                data.setChild(childList);
//            }
//            list.add(data);
//        }
//
//        RecyclerView recyclerView = root.findViewById(R.id.recycler);
//        recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
//        recyclerView.setAdapter(new ExpandableRecyclerAdapter(list));

//        final TextView textView = root.findViewById(R.id.text_home);
//        final CircularProgressButton button = root.findViewById(R.id.buttonPanel);
//        button.setProgress(50);
////        button.setCompleteText("sds");
//        button.setErrorText("sdsdsds");
//        button.postDelayed(new Runnable() {
//            @Override
//            public void run() {
//                button.setProgress(-1);
//            }
//        }, 5000L);
//        homeViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
//            @Override
//            public void onChanged(@Nullable String s) {
//                textView.setText(s);
//            }
//        });

        return root;
    }
}